package info.motteke.mixivoice4j.http.json.comment.delete;

import info.motteke.mixivoice4j.Comment;
import info.motteke.mixivoice4j.Entry;
import info.motteke.mixivoice4j.User;
import info.motteke.mixivoice4j.http.json.JsonRequestBuilder;

public class DeleteCommentBuilder extends JsonRequestBuilder<DeleteCommentRequest> {

    private Entry entry = null;

    private Comment comment = null;

    private User user = null;

    protected DeleteCommentBuilder() {

    }

    public DeleteCommentBuilder comment(Comment comment) {
        this.comment = comment;
        this.entry = comment.getParent();
        return this;
    }

    public DeleteCommentBuilder user(User user) {
        this.user = user;
        return this;
    }

    @Override
    public DeleteCommentRequest build() {
        check(entry, "entry");
        check(comment, "comment");
        check(user, "user");

        DeleteCommentRequest req = new DeleteCommentRequest();
        DeleteCommentParam p = req.getParams();
        p.setEntryId(entry.getId());
        p.setOwnerId(entry.getUser().getId());
        p.setCommentId(comment.getId());
        p.setCommentMemberId(comment.getUser().getId());
        p.setViewerId(user.getId());

        return req;
    }
}